/*
 * ChooseAddressHolder.java
 * business
 *
 * Created by SunDing on 2016/9/9.
 *
 * Copyright (c) 2016年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.widget.listview.viewholder;

import android.view.View;
import android.widget.CheckBox;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.yidiandao.business.R;
import com.yidiandao.business.data.bean.UserAddress;
import com.yidiandao.business.ui.widget.listview.ViewHolder;

/**
 * 选择地址 ViewHolder
 */
public class ChooseAddressHolder extends ViewHolder {

    public RelativeLayout mRlytSelect;
    public CheckBox mCbSelect;
    private TextView mTvName;
    private TextView mTvNumber;
    private TextView mTvAddress;

    @Override
    protected void initView(View rootView) {
        mTvName = (TextView) rootView.findViewById(R.id.tv_name);
        mTvNumber = (TextView) rootView.findViewById(R.id.tv_number);
        mRlytSelect = (RelativeLayout) rootView.findViewById(R.id.rlyt_select);
        mCbSelect = (CheckBox) rootView.findViewById(R.id.cb_select);
        mTvAddress = (TextView) rootView.findViewById(R.id.tv_address);
    }

    @Override
    protected int getItemLayoutId() {
        return R.layout.item_choose_address;
    }

    public void refreshUI(UserAddress userAddress) {
        String address = userAddress.getProvince()
                + userAddress.getCity()
                + userAddress.getDistrict()
                + userAddress.getAddress();

        mTvName.setText(userAddress.getConsignee());
        mTvNumber.setText(userAddress.getTel());
        mTvAddress.setText(address);
        mCbSelect.setChecked(userAddress.isSelected());
    }
}
